/**
 * Copyright 2010 Zhou Zhao
 *
 * This file is part of FPGA compiler for EE680 USC
 *
   FPGA compiler is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   FPGA compiler is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * In the global routing, each switchbox is modeled in class of "switchBox", which
 * has fields of "id", "x", "y" coordinates, "weight" for congestion computation,
 * "color" for visualization. Note the field "weightWave" is used for wave
 * propagation in weighted grid, so it is cleared after routing each net. In
 * addition, boolean field "update" is assigned TRUE once the vertex is computed.
 */

package edu.usc.ee.java;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Zhou Zhao
 * @version 1.0
 */

public class switchBox {

    private int id;
    private int x;
    private int y;
    private int weight;
    private int weightWave;
    private myColor color;
    private boolean update;

    private List<Integer> north;
    private List<Integer> south;
    private List<Integer> east;
    private List<Integer> west;

    public switchBox()
    {}

    public switchBox(int id, int x, int y, int row_max, int col_max)
    {
        this.id = id;
        this.x = x;
        this.y = y;
        this.weight = 1;
        this.weightWave = 0;
        this.color = myColor.RED;
        this.update = false;

        this.north = new ArrayList<Integer>(col_max);
        this.south = new ArrayList<Integer>(col_max);
        this.east = new ArrayList<Integer>(row_max);
        this.west = new ArrayList<Integer>(row_max);
    }

    public switchBox(int id, int x, int y, int weight, myColor color)
    {
        this.id = id;
        this.x = x;
        this.y = y;
        this.weight = weight;
        this.color = color;
    }

    public int getID()
    {
        return this.id;
    }

    public int getx()
    {
        return this.x;
    }

    public int gety()
    {
        return this.y;
    }

    public int getWeight()
    {
        return this.weight;
    }

    public void setWeight(int weight)
    {
        this.weight = weight;
    }

    public int getWeightWave()
    {
        return this.weightWave;
    }

    public void setWeightWave(int weightWave)
    {
        this.weightWave = weightWave;
    }

    public myColor getColor()
    {
        return this.color;
    }

    public void setColor(myColor color)
    {
        this.color = color;
    }

    public boolean getUpdate()
    {
        return this.update;
    }

    public void setUpdate(boolean update)
    {
        this.update = update;
    }

    @Override
    public String toString()
    {
        return "V"+id+"("+x+","+y+")";
    }

    public void addNorth(Integer net){
        this.north.add(net);
    }

    public List<Integer> getNorth(){
        return this.north;
    }

    public void addSouth(Integer net){
        this.south.add(net);
    }

    public List<Integer> getSouth(){
        return this.south;
    }

    public void addEast(Integer net){
        this.east.add(net);
    }

    public List<Integer> getEast(){
        return this.east;
    }

    public void addWest(Integer net){
        this.west.add(net);
    }

    public List<Integer> getWest(){
        return this.west;
    }
    
}
